<?php
require('functions/pageLoad.php');

if($_SERVER['REQUEST_METHOD'] == 'POST'){

// insert letting

$lettingsQuery="INSERT INTO faqs SET question = '".$_POST['question']."', answer = '".$_POST['answer']."', tradesman = '".$_POST['tradesman']."', user = '".$_POST['user']."'";
$lettingsResult=mysql_query( $lettingsQuery ) or die ("Error in query: $lettingsQuery . " . mysql_error());

$new_id = mysql_insert_id();

header("Location: edit_faqs.php?id=".$new_id);
exit;

}

require('includes/meta.php');
require('includes/header.php');
require('includes/leftColumn.php');
?><div id="middleColumn"><div id="content">

<h2>Add new FAQ</h2>
<form method="post" action="add_faqs.php" id="adminFAQForm" style="float: left; padding-top: 10px;">

<div style="float: left; width: 100%">
<div class="formInputLeft"><label for="tradesman">Tradesman:</label></div>
<div class="formInputRight"><input type="checkbox" id="tradesman" name="tradesman" value="1" /></div>
</div>

<div style="float: left; width: 100%">
<div class="formInputLeft"><label for="user">User:</label></div>
<div class="formInputRight"><input type="checkbox" id="user" name="user" value="1" /></div>
</div>

<div style="float: left; width: 100%">
<div class="formInputLeft"><label for="question">Question:</label></div>
<div class="formInputRight"><input type="text" class="textbox" id="question" name="question" style="width: 300px;" value="" /></div>
</div>

<div style="float: left; width: 100%">
<div class="formInputLeft">Answer:</div>
<div class="formInputRight"><textarea name="answer" rows="7" cols="35"></textarea></div>
</div>

<div class="formInputLeft"><a onclick="return validateFAQForm();" class="button" style="color: #ffffff;">Add FAQ</a></div><div class="formInputRight" id="jsErr" style="padding-top: 10px; color: #ff0000;"></div>

</form>

</div>
</div>
</div>

<?php
require('includes/footer.php');
?>